package Offer.q04_findNumberIn2DArray;

public class Solution {
    public static void main(String[] args) {

    }
    public boolean findNumberIn2DArray(int[][] matrix, int target) {
        if (matrix.length == 0) {
            return false;
        }
        int m = matrix.length;
        int n = matrix[0].length;

        for (int i = 0, j = n - 1; i < m && j >= 0; ) {
            if (target == matrix[i][j]) {
                return true;
            }
            if (target > matrix[i][j]) {
                i++;
                continue;
            }
            if (target < matrix[i][j]) {
                j--;

            }
        }
        return false;
    }
}
